﻿#region Usings

using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using ScrumTable.BL.DM.DataManagement;
using ScrumTable.UI.ViewModel;

#endregion

namespace ScrumTable.UI.View.WinTouch.UserControls
{
    /// <summary>
    /// This class shows the right item-control for a given datacontext
    /// </summary>
    public class ScrumItemControl : UserControl
    {
        public ScrumItemControl()
        {
            DataContextChanged += OnDataContextChanged;
        }

        private void OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            DataContextChanged -= OnDataContextChanged;
            
            if (DataContext is UserStoryViewModel)
            {
                Content = new UserStoryControl() { DataContext = DataContext };
                return;
            }
            if( DataContext is BugViewModel)
            {
                Content = new BugControl(){DataContext = DataContext};
                return;
            }
            if ( DataContext is TaskViewModel)
            {
                Content = new TaskControl() { DataContext = DataContext }; ;
                return;
            }
        }
    }
}
